package cn.idietrade.idietradeusermodule8004.service.impl;

import cn.idietrade.common.pojo.SecondUser;
import cn.idietrade.idietradeusermodule8004.mapper.SecondUserMapper;
import cn.idietrade.idietradeusermodule8004.service.SecondUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SecondUserServiceImpl implements SecondUserService {

    @Resource
    private SecondUserMapper userMapper;

    @Override
    public Integer register(SecondUser user) {
        SecondUser secondUser = null;
        secondUser = userMapper.checkAccount(user.getAccount());
        if (secondUser == null){
            int flag = userMapper.addUser(user);
            return flag;
        }
        return -1;
    }

    @Override
    public List<SecondUser> getUserList() {
        return userMapper.getUserList();
    }

    @Override
    public SecondUser login(String account, String password) {
        SecondUser secondUser = userMapper.login(account,password);
        return secondUser;
    }

    @Override
    public Integer updateUser(SecondUser user) {
        return userMapper.updateUser(user);
    }

    @Override
    public Integer modifyUserPermission(Integer id, Integer permission) {
        return userMapper.modifyUserPermission(id, permission);
    }
}
